{include file="public/admin_head.html"}
<style>
.table{
	width:100%;
}

.table tbody tr td{
	text-align:left;
}

input[type="checkbx"] {
	vertical-align: top;
	margin-left:20px
}
</style>

<body>

	<legend style="margin-top:30px">
		<B>关键词自动回复列表</B>
		<span style="float:right;margin-right:20px">
			<a href="./index.php?act=message&st=messageAdd" class="btn btn-primary">添加规则</a>
		</span>
	</legend>
	<table>
        <tr>
            <td class="span2" style="text-align: right;">
                <div class="control-group">
                    <label class="control-group" for="fm_searchbox">关键词搜索：</label>
                </div>
            </td>
            <td class="span3">
                <div class="input-append">
                    <input class="span2" id="txt_keywords" type="text" value="{$keyword}">
                    <button class="btn" type="button" onclick="search();">搜索</button>
                </div>
            </td>
            <td>
         </tr>
    </table>
	<table class="table table-bordered table-striped" align="center" style="width:90%">
		<tr>
			
			<th style="width: 200px;">规则名称</th>
			<th style="width: 300px;">关键字</th>
			<th style="width: 150px;">添加时间</th>
			<th style="width:100px">操作</th>
			
		</tr>
{foreach item=message from=$msg_list}	
		<tr id="tr_{$message.id}">
			
			<td style="text-align:center">{$message.rule_name}</td>
			<td style="text-align:center">{$message.keywords}</td>
			<td style="text-align:center">{$message.raw_add_time}</td>
			<td style="text-align:center">
				<a class="btn" href="/index.php?act=message&st=messageEdit&id={$message.id}">编辑</a>
				<button class="btn btn-warning" type="button" onclick="checkDel({$message.id});">删除</button>
			</td>
		 </tr>
{/foreach}	
		<table  width="100%">
			<tr>
				<td class="form-actions pagination" align="center">{$pageShow}</td>
			</tr>
		</table>
	</table>		
{include file="public/admin_foot.html"}
<script type="text/javascript">
function checkDel(message_id) {
	if(confirm("你确定要删除这条规则吗？")) {
		$.ajax({
			data:{'id':message_id},
			url:'/index.php?act=message&st=messageDelete',
			type:"GET",
			timeout:15000,
			dataType:'json',
			success:function(data) {
				if(typeof data.result != 'undefined' && data.result =='ok') {
					//window.location.reload();
					$("#tr_"+message_id).remove();
				} else if(typeof data.result != 'undefined' && data.result =='offline') {
					alert("您尚未登录或者登录已超时，请重新登录！");
					window.location.href = '/index.php?act=admin&st=adminLogin';
				}
			},
			error:function(data) {
				alert("系统繁忙，稍后再试！");
			}
		});
	}
}
function search() {
	var keywords = $.trim($("#txt_keywords").val());
	window.location.href = "{$host}/index.php?act=message&st=main&keyword="+encodeURIComponent(keywords);
}
</script>
